---
title: Save a rendered report to disk
summary: Renders (if needed) a report/letter and writes the resulting bytes to a destination file.
status: draft
owner: SAIF Case Management
last_reviewed: 2026-08-21
library: SAIF.Services.Printing
reference_type: embedded
operation_id: OP-REPORTING-SAVE
trigger: Caller invokes Reporting.ReportBase.Save
---

# Save a rendered report to disk

Persists a rendered report/letter's PDF bytes to a destination file on disk, rendering the report first if necessary.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-REPORTING-SAVE |
| **Trigger** | Caller invokes `Reporting.ReportBase.Save(overwrite)` |
| **Inputs** | `DestinationFileName`, `overwrite` flag |
| **Outputs** | Boolean (whether the destination file exists after the operation) |
| **Primary components** | `Reporting.ReportBase.Save` |
| **Entry point** | `SAIF.Services.Printing\Reporting\ReportBase.vb` |

## Steps

1. Checks whether `DestinationFileName` already exists on disk.
2. If it does not exist, or `overwrite` is requested, and `DestinationFileName` is non-empty: calls [Render a letter or report](render-report.md) to ensure `m_reportFile` is populated, then writes the bytes to `DestinationFileName` using a `FileStream` opened with `FileMode.Create` (truncates/creates).
3. Returns whether the destination file exists after the operation.

## Process flow

```mermaid
flowchart TD
	Start([Save called]) --> Exists{DestinationFileName exists?}
	Exists -->|Yes and not overwrite| EndOk([Return True, file exists])
	Exists -->|No or overwrite| CheckName{DestinationFileName non-empty?}
	CheckName -->|No| EndSkip([Skip write])
	CheckName -->|Yes| Render[Call Render to populate m_reportFile]
	Render --> Write[Write bytes via FileStream FileMode.Create]
	Write --> EndOk
```

## Failure and edge-case behavior
- If `DestinationFileName` is empty, no write occurs and the return value reflects whatever existed before the call.*

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Services.Printing\Reporting\ReportBase.vb`
